/*
 * Buzzer.cpp
 *
 *  Created on: 2015年5月19日
 *      Author: chris
 */
#include <Arduino.h>
#include "Buzzer.h"

void Buzzer::Init(const int pin)
{
	_pin = pin;
	_state = false;
	pinMode(pin, OUTPUT);
	digitalWrite(pin, LOW);
	return;
}

void Buzzer::On(void)
{
	if (_state == false)
	{
		digitalWrite(_pin, HIGH);
		_state = true;
	}
}

void Buzzer::Off(void)
{
	if (_state == true)
	{
		digitalWrite(_pin, LOW);
		_state = false;
	}
}

void Buzzer::Toggle(void)
{
	if (_state == true)
	{
		digitalWrite(_pin, LOW);
	}
	else
	{
		digitalWrite(_pin, HIGH);
	}
	_state = !_state;
}
